package com.bjpowernode.springboot.web;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.Map;

@Controller
public class UserController {

    @RequestMapping(value = "/user/detail")
    @ResponseBody
    public Object userDetail(){

        Map<String,Object> retMap = new HashMap<>();

        retMap.put("id",1001);
        retMap.put("userName","sun");

        return retMap;
    }

    /*@RequestMapping(value = "/user/page/detail")
    public String userPageDetail(Model model){
        model.addAttribute("id",1001);
        model.addAttribute("userName","sun");
        return "UserDetail";
    }*/


    @RequestMapping(value = "/user/page/detail")
    /*@ResponseBody*/
    public ModelAndView userPageDetail(){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("id",1001);
        modelAndView.addObject("userName","sun");
        modelAndView.setViewName("UserDetail");
        return modelAndView;
    }

    /*ModelAndView mv = new ModelAndView();
        mv.addObject("myname",name);
        mv.addObject("myage",age);
        mv.setViewName("show");
        return mv;*/

}
